#!/bin/sh

. /usr/share/libubox/jshn.sh

dev_info=/etc/config/dev_info

if [ -e "$dev_info" ];then
	rm "$dev_info"
fi

touch $dev_info
uci set dev_info.dev_info=dev_info

json_load "$(config_util -r)"
json_select "ow_info"

json_get_var HW_ID HW_ID
json_get_var DG_VER DG_VER
json_get_var PRODUCT_ID PRODUCT_ID
json_get_values RETAIL_REGION RETAIL_REGION

uci set dev_info.dev_info.hw_id=$HW_ID
uci set dev_info.dev_info.dg_ver=$DG_VER
uci set dev_info.dev_info.product_id=$PRODUCT_ID
for region in $RETAIL_REGION; do
	uci add_list dev_info.dev_info.retail_region=$region
done
uci commit dev_info
